﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace RegularExpresions
{
    class RefularExpresionsTests
    {
        static void Main(string[] args)
        {
            //string text = "Testing is important. We need to test everything.";
            //string pattern = (@"(t|T){1}(e|E){1}(s|S){1}(t|T){1}\w*");
            //Match found = Regex.Match(text, pattern);
            //while (found.Success)
            //{
            //    Console.WriteLine(found.Value);
            //    found = found.NextMatch();
            //}

            string[] text = { "0", "33", "-2381.78132", "4.3347", "12.00","-0.0","-0","-0.01",
                                "0.34", "+3", "24 543", "01.23", "12.", "11,23", "--2", ".25", "-.25", "12е7" };
            string pattern = (@"(\A(0|(-?[1-9]{1}[0-9]*)){1}(\.([0-9]+))?\Z)|(-0{1}\.{1}[0-9]*[1-9]+[0-9]*)");
            foreach (var item in text)
            {
                Match found = Regex.Match(item, pattern);
                if (found.Success)
                {
                    Console.WriteLine(found.Value);
                }
            }

            //string text = "dasd@das.ff sdaskl daslk erq@asd.asdda.aa sdasda@sdda.ds.info o6tedasda@dsas dasdasda@dasda.sssss";
            //string pattern = (@"[\w]+@{1}[\w]+(\.{1}\w+)*(\.{1}(\w){2,4})+\b");
            //Match found = Regex.Match(text, pattern);
            //while (found.Success)
            //{
            //    Console.WriteLine(found.Value);
            //    found = found.NextMatch();
            //}
            
        }
    }
}
